<?php
$page_association="visuals.php";
$page_title="Iris";
include("header.php");
$width = 140;
$height = 100;
$pixel = 1;
$scale = 2;
?>
<center><canvas id="canvas" width="<?php echo $width * $pixel; ?>" height="<?php echo $height * $pixel; ?>"></canvas></center>
<center><div id="error"></div></center>
<script language="javascript" type="text/javascript">

VisualsStop();

width = <?php echo $width; ?>;
height = <?php echo $height; ?>;
pixel = <?php echo $pixel; ?>;
scale = <?php echo $scale; ?>;
needs_init = true;
drawMode = 0;
fgcolor = 0xfff;
bgcolor = 0x000;
line_blend_mode = 2;
clearFrame = true;
framerate = 100;
redraw = false;

var ex = 0;
var ey = 0;
var ez = 0;
var pi = 0;

var count = 1
function init() {
	pi=acos(-1);
	sp=10;
	siz=1;
	vi=5;
	sn=1000000;
	tb = 1;
	cn=0.5;
	tx = 100;
	ty = 0;
	tz = 0;
	u = 1;
	count = 0;
}

function frame() {
	n=sqrt(w*w+h*h)*pi*sn*siz/6*(1+equal(tb,2)) + 500;
	ex=ex+tx*sp;ey=ey+ty*sp;ez=ez+tz*sp;
	kx=if2(vi,sin(ex)*pi/8,-pi/2+sin(ex)*pi/8);
	ky=if2(vi,sin(ey)*pi/8,ey);
	kz=if2(vi,ez,sin(ez)*pi/8);
	sx=sin(kx);
	sy=sin(ky);
	sz=sin(kz);
	cx=cos(kx);
	cy=cos(ky);
	cz=cos(kz);
}

function beat() {
	mx=v;
	my=(random(100) - 50) / 50;
	mz=(random(100) - 50) / 50;
	tx=(1-abs(mx))*if2(mx,sign(mx),1);ty=(1-abs(my))*if2(my,sign(my),1);tz=(1-abs(mz))*if2(mz,sign(mz),1);
}

function point() {
	r=i*pi*2*sn;d=((i*sn)%sn+1)/sn*1.2;u=if2(equal(tb,2),1-u,tb);
	x1=sin(r)*d*siz;y1=cos(r)*d*siz;z1=(1-v)*siz*(u*2-1);
	y2=y1*cx-z1*sx;z2=y1*sx+z1*cx; x2=z2*sy+x1*cy;z3=z2*cy-x1*sy; x3=x2*cz-y2*sz;y3=y2*cz+x2*sz; x=x3/(1+z3/3);y=y3/(1+z3/3);
	cl=sqrt(2)/4*3-z3; red=cl*(sin(d/1.2*pi*2)/2+0.5);green=cl*(sin(d/1.2*pi*2+pi*2/3)/2+0.5);blue=cl*(sin(d/1.2*pi*2+pi*4/3)/2+0.5);
}

var scope = new r_sscope("Iris", init, frame, beat, point);
var bright = new r_fastbright("Bright", 0);
AddLink(scope);
AddLink(bright);

VisualsStart();
</script>
<?php
include("footer.php");
?>
